<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/framework/tcp/framework/Server.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_5752cadd8276ecfd63d9b924f2a4d4b5.html">framework</a></li><li class="navelem"><a class="el" href="dir_c67741c6509c9bd4aec6faa9fd694608.html">tcp</a></li><li class="navelem"><a class="el" href="dir_cf0ab36ee90451b75992f2af7ab5af86.html">framework</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Server.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_server_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __SERVER_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __SERVER_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_service_8h.html">Service.h</a>&quot;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;../../../socket/SockError.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<a class="code" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="keyword">class </span><a class="code" href="class_c_tcp_io_server.html">CTcpIoServer</a>;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="keyword">class </span><a class="code" href="class_client.html">Client</a>;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<a class="code" href="_server_8h.html#a3110e5572662bb6a33362b53f5b9ecde">EXPORT_SHARED_PTR</a>(<a class="code" href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a>, <a class="code" href="class_c_tcp_io_socket.html">CTcpIoSocket</a>);</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<a class="code" href="_server_8h.html#a3110e5572662bb6a33362b53f5b9ecde">EXPORT_SHARED_PTR</a>(<a class="code" href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a>, <a class="code" href="class_c_tcp_io_server.html">CTcpIoServer</a>);</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160; </div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="class_server.html">   13</a></span>&#160;<span class="keyword">class </span><a class="code" href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a> <a class="code" href="class_server.html">Server</a> :<span class="keyword">public</span> <a class="code" href="class_service.html">Service</a></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;{</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    <a class="code" href="class_service.html#a62c2f070662951afc86079973d1e1852">delete_class_copy_operator</a>(<a class="code" href="class_server.html">Server</a>);</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    <a class="code" href="class_server.html">Server</a>();</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="class_server.html">Server</a>();</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160; </div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_service.html#a2d41738423a6eafacc44af90ca6c6ef7">Init</a>(<span class="keyword">const</span> <a class="code" href="class_tcp_config.html">TcpConfig</a>&amp; c);</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160; </div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_service.html#aad0c7b096b5dc39a0a763997f045c2d5">Run</a>();</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_service.html#ae7f2c04b1f26bcb86e59beb2f7dcbeed">NotifyExit</a>();</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_service.html#a7f9f9d3c3033b32ce108509093a7ff08">PostConnect</a>(<span class="keywordtype">void</span>* invoker = <a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>, <span class="keyword">const</span> <span class="keywordtype">char</span>* addr = <a class="code" href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a>, <a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> port = 0);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160; </div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="class_server.html#a97d9351a4f3b94d46bc353246c95123b">   41</a></span>&#160;    <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="class_server.html#a97d9351a4f3b94d46bc353246c95123b">GetName</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">&quot;Server&quot;</span>; }</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_service.html#a24501c6a89af8f6781ef96b423644780">Post</a>(<a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a>(*complete)(<span class="keywordtype">void</span>*), <span class="keywordtype">void</span>* invoker);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="class_service.html#acad19cb7557fac6e504af4fb5c734d4e">DealConnect</a>(<a class="code" href="class_client.html">Client</a>* c, <span class="keyword">const</span> <span class="keywordtype">char</span>* msg, <span class="keywordtype">void</span>* invoker);</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="class_server.html#ac43591a38a0fad67544d6b09d2604f29">   63</a></span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="class_server.html#ac43591a38a0fad67544d6b09d2604f29">SetSocketOpt</a>(<a class="code" href="class_c_tcp_io_socket.html">CTcpIoSocket</a>* s) { <span class="keywordflow">return</span> <span class="keyword">true</span>; }</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keywordtype">void</span> SetClient(<a class="code" href="class_client.html">Client</a>* c);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keywordtype">void</span> PostAccept(<span class="keywordtype">void</span>* invoker);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keyword">static</span> <a class="code" href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a> AcceptComplete(<a class="code" href="class_c_sock_error.html">CSockError</a> ec, <span class="keywordtype">void</span>* invoker);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keyword">virtual</span> <a class="code" href="class_c_basic_service.html">CBasicService</a>* <a class="code" href="class_service.html#a9ea329d8d3607adcd3e03a94a0585217">GetTcpService</a>() <span class="keyword">const</span>;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="class_server.html#ac27a342724c595745fea924a5ec116c6">   71</a></span>&#160;    <a class="code" href="class_shared_ptr.html">SharedPtr&lt;CTcpIoServer&gt;</a> <a class="code" href="class_server.html#ac27a342724c595745fea924a5ec116c6">_tcpServer</a>;     </div>
<div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">   72</a></span>&#160;    <a class="code" href="class_shared_ptr.html">SharedPtr&lt;CTcpIoSocket&gt;</a> <a class="code" href="class_server.html#ae87994e288d29da1f351d80ed04f387b">_svrSock</a>;       </div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;};</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<a class="code" href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="preprocessor">#endif // __SERVER_H__</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_c_sock_error_html"><div class="ttname"><a href="class_c_sock_error.html">CSockError</a></div><div class="ttdoc">套接字错误信息类</div><div class="ttdef"><b>Definition:</b> <a href="_sock_error_8h_source.html#l00013">SockError.h:13</a></div></div>
<div class="ttc" id="aclass_service_html_aad0c7b096b5dc39a0a763997f045c2d5"><div class="ttname"><a href="class_service.html#aad0c7b096b5dc39a0a763997f045c2d5">Service::Run</a></div><div class="ttdeci">virtual bool Run()=0</div></div>
<div class="ttc" id="aclass_server_html"><div class="ttname"><a href="class_server.html">Server</a></div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00013">Server.h:13</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html"><div class="ttname"><a href="class_shared_ptr.html">SharedPtr&lt; CTcpIoServer &gt;</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_server_html"><div class="ttname"><a href="class_c_tcp_io_server.html">CTcpIoServer</a></div><div class="ttdoc">tcp io服务端服务类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_server_8h_source.html#l00011">TcpIoServer.h:11</a></div></div>
<div class="ttc" id="atools_8h_html_a201ce692c9dca6599e5c12d00167419b"><div class="ttname"><a href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div><div class="ttdeci">#define DEF_BEG_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00036">tools.h:36</a></div></div>
<div class="ttc" id="aclass_tcp_config_html"><div class="ttname"><a href="class_tcp_config.html">TcpConfig</a></div><div class="ttdoc">客户端配置类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_conf_8h_source.html#l00018">TcpConf.h:18</a></div></div>
<div class="ttc" id="atools_8h_html_a64152c8b939d1ce06c7c5cb6c97b62f8"><div class="ttname"><a href="tools_8h.html#a64152c8b939d1ce06c7c5cb6c97b62f8">LIBTOOLS</a></div><div class="ttdeci">#define LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00095">tools.h:95</a></div></div>
<div class="ttc" id="aclass_service_html_a7f9f9d3c3033b32ce108509093a7ff08"><div class="ttname"><a href="class_service.html#a7f9f9d3c3033b32ce108509093a7ff08">Service::PostConnect</a></div><div class="ttdeci">virtual void PostConnect(void *invoker=NullPtr, const char *addr=NullPtr, DWORD port=0)=0</div><div class="ttdoc">投递连接、接收请求</div></div>
<div class="ttc" id="aclass_service_html"><div class="ttname"><a href="class_service.html">Service</a></div><div class="ttdoc">服务基类</div><div class="ttdef"><b>Definition:</b> <a href="_service_8h_source.html#l00019">Service.h:19</a></div></div>
<div class="ttc" id="aclass_server_html_ac27a342724c595745fea924a5ec116c6"><div class="ttname"><a href="class_server.html#ac27a342724c595745fea924a5ec116c6">Server::_tcpServer</a></div><div class="ttdeci">SharedPtr&lt; CTcpIoServer &gt; _tcpServer</div><div class="ttdoc">tcp服务类</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00071">Server.h:71</a></div></div>
<div class="ttc" id="aclass_service_html_a9ea329d8d3607adcd3e03a94a0585217"><div class="ttname"><a href="class_service.html#a9ea329d8d3607adcd3e03a94a0585217">Service::GetTcpService</a></div><div class="ttdeci">virtual CBasicService * GetTcpService() const =0</div><div class="ttdoc">获取tcp底层类指针</div></div>
<div class="ttc" id="atools_8h_html_ac909db71799bb22cb7d636a34cd785e4"><div class="ttname"><a href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div><div class="ttdeci">#define DEF_END_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00038">tools.h:38</a></div></div>
<div class="ttc" id="aclass_service_html_ae7f2c04b1f26bcb86e59beb2f7dcbeed"><div class="ttname"><a href="class_service.html#ae7f2c04b1f26bcb86e59beb2f7dcbeed">Service::NotifyExit</a></div><div class="ttdeci">virtual void NotifyExit()=0</div><div class="ttdoc">通知退出</div></div>
<div class="ttc" id="aclass_service_html_acad19cb7557fac6e504af4fb5c734d4e"><div class="ttname"><a href="class_service.html#acad19cb7557fac6e504af4fb5c734d4e">Service::DealConnect</a></div><div class="ttdeci">virtual int DealConnect(Client *c, const char *msg, void *invoker)=0</div><div class="ttdoc">处理连接</div></div>
<div class="ttc" id="aclass_service_html_a24501c6a89af8f6781ef96b423644780"><div class="ttname"><a href="class_service.html#a24501c6a89af8f6781ef96b423644780">Service::Post</a></div><div class="ttdeci">virtual void Post(DWORD(*complete)(void *), void *invoker)=0</div><div class="ttdoc">投递一个用户操作</div></div>
<div class="ttc" id="aclass_server_html_ac43591a38a0fad67544d6b09d2604f29"><div class="ttname"><a href="class_server.html#ac43591a38a0fad67544d6b09d2604f29">Server::SetSocketOpt</a></div><div class="ttdeci">virtual bool SetSocketOpt(CTcpIoSocket *s)</div><div class="ttdoc">设置套接字额外选项</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00063">Server.h:63</a></div></div>
<div class="ttc" id="a_service_8h_html"><div class="ttname"><a href="_service_8h.html">Service.h</a></div></div>
<div class="ttc" id="atools_8h_html_a798af1e30bc65f319c1a246cecf59e39"><div class="ttname"><a href="tools_8h.html#a798af1e30bc65f319c1a246cecf59e39">DWORD</a></div><div class="ttdeci">unsigned int DWORD</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00134">tools.h:134</a></div></div>
<div class="ttc" id="aclass_service_html_a62c2f070662951afc86079973d1e1852"><div class="ttname"><a href="class_service.html#a62c2f070662951afc86079973d1e1852">Service::delete_class_copy_operator</a></div><div class="ttdeci">delete_class_copy_operator(Service)</div></div>
<div class="ttc" id="atools_8h_html_ab689500aaec0db066e3ac9483d3fe425"><div class="ttname"><a href="tools_8h.html#ab689500aaec0db066e3ac9483d3fe425">NullPtr</a></div><div class="ttdeci">#define NullPtr</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00119">tools.h:119</a></div></div>
<div class="ttc" id="a_server_8h_html_a3110e5572662bb6a33362b53f5b9ecde"><div class="ttname"><a href="_server_8h.html#a3110e5572662bb6a33362b53f5b9ecde">EXPORT_SHARED_PTR</a></div><div class="ttdeci">EXPORT_SHARED_PTR(LIBTOOLS, CTcpIoSocket)</div></div>
<div class="ttc" id="aclass_service_html_a2d41738423a6eafacc44af90ca6c6ef7"><div class="ttname"><a href="class_service.html#a2d41738423a6eafacc44af90ca6c6ef7">Service::Init</a></div><div class="ttdeci">virtual bool Init(const TcpConfig &amp;c)=0</div><div class="ttdoc">初始化工作</div></div>
<div class="ttc" id="aclass_server_html_a97d9351a4f3b94d46bc353246c95123b"><div class="ttname"><a href="class_server.html#a97d9351a4f3b94d46bc353246c95123b">Server::GetName</a></div><div class="ttdeci">virtual const char * GetName() const</div><div class="ttdoc">返回客户端名称</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00041">Server.h:41</a></div></div>
<div class="ttc" id="aclass_c_basic_service_html"><div class="ttname"><a href="class_c_basic_service.html">CBasicService</a></div><div class="ttdoc">服务类 基类</div><div class="ttdef"><b>Definition:</b> <a href="_service_base_8h_source.html#l00015">ServiceBase.h:15</a></div></div>
<div class="ttc" id="aclass_c_tcp_io_socket_html"><div class="ttname"><a href="class_c_tcp_io_socket.html">CTcpIoSocket</a></div><div class="ttdoc">用于tcp进行io投递的套接字类</div><div class="ttdef"><b>Definition:</b> <a href="_tcp_io_socket_8h_source.html#l00017">TcpIoSocket.h:17</a></div></div>
<div class="ttc" id="aclass_client_html"><div class="ttname"><a href="class_client.html">Client</a></div><div class="ttdef"><b>Definition:</b> <a href="_client_8h_source.html#l00012">Client.h:12</a></div></div>
<div class="ttc" id="aclass_server_html_ae87994e288d29da1f351d80ed04f387b"><div class="ttname"><a href="class_server.html#ae87994e288d29da1f351d80ed04f387b">Server::_svrSock</a></div><div class="ttdeci">SharedPtr&lt; CTcpIoSocket &gt; _svrSock</div><div class="ttdoc">服务套接字</div><div class="ttdef"><b>Definition:</b> <a href="_server_8h_source.html#l00072">Server.h:72</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
